package com.zodiac.app.datathinking.szse.b0602;

import com.alibaba.fastjson.JSON;
import com.zodiac.app.datathinking.szse.Processors;
import com.zodiac.app.datathinking.szse.Transfer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

@Processors(B0602Processor.class)
@Component
public class B0602Transfer implements Transfer<List> {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void transfer(List request) {
        if (Objects.isNull(request) || request.isEmpty()) {
            return;
        }
        mongoTemplate.insert(JSON.parseArray(JSON.toJSONString(request), B0602Model.class), B0602Model.class);
    }
}
